February 1996

A look at Solaris routing

When you install a Solaris network, much of the work involved in getting information from one machine to another deals with routing. When configuring Solaris, you choose the naming service (if any) that determines how packets are routed to other connected systems. When you make this decision, you define the routing table maintained in the Solaris kernel. A number of programs may add or delete routes from the routing tables, including route, ifconfig, in.routed, and in.rdisc.

In this article, we'll discuss Solaris routing in general and then show you how you can change your network routes. We'll also show you how IP addresses, netmasks, and subnets affect routing on your Solaris system.

A routing overview

The routing table in the Solaris kernel consists of three types of routes. They are

Routes determine the pathway for packets on your network to reach a destination. Each packet contains some form of route information.

The system first checks host routes, which define a route to a single host. It checks network routes second; they determine a route to all the hosts on a single network. Default routes, used when no host or network routes to a destination are found, usually send the packets to a more knowledgeable system that has a better chance of finding a route to a destination.

A packet on a given network must pass through several routers to reach its destination. Each router decides how a packet gets sent by determining which type of route was used. You can configure each system on your network to handle the routing of packets in one of two ways.

The first of these is static routing. Static routing involves defining the routing tables when the system boots. These tables won't change, but you can add and remove static routes with the route command. We'll demonstrate how to do this later in this article.

The second routing configuration is dynamic routing. When you use dynamic routing on your system, the routing tables in your kernel update by interacting with a routing daemon. Solaris uses the daemon in.routed to exchange routing information between hosts. The in.routed daemon uses RIP (Routing Information Protocol) packets to exchange updates in routing information.

Solaris also uses another daemon, in.rdisc, in a dynamic routing configuration. This daemon updates default routes on your system using Router Discovery Packets to exchange information. We'll discuss both of these daemon configurations later in this article.

In addition to these daemons, the ifconfig program always adds routes when interfaces are launched. For example, in a point-to-point interface, ifconfig creates a route to the PPP host on a client machine after a connection is made.

When discussing routing, you should always remember that each system on your network is one of two types, either a router or a host. A system with more than one interface is defined as a router. If the routing daemons in.routed and in.rdisc run on a router, they broadcast routing information. These machines automatically forward IP packets. If a system has only one interface, it is defined as a host. If the routing daemons run on these systems, they listen for routing information instead of broadcasting it.

How Solaris starts routing

On Solaris systems, routing is determined by the presence or absence of the file

/etc/defaultrouter

When your system boots, it checks to see if this file exists. If so, it uses only static routing with the static default route created to the machine that's named in the /etc/defaultrouter file.

When the system boots and finds no /etc/defaultrouter file, it then checks for the number of interfaces configured. If the system is a router, having more than one interface, the in.routed and in.rdisc daemons run and broadcast routing information.

If the machine is a host, only the in.rdisc daemon loads and listens for Routing Discovery Packets. If it finds any of these packets, the host will use in.rdisc as the dynamic routing program. If it finds no Routing Discovery Packets, the daemon will quickly terminate. When this daemon terminates, the in.routed daemon loads and listens for routers broadcasting RIP packets.

Setting a default router

For systems containing a lot of local packets and few network packets, you may want to consider defining a default router. By doing so, all non-local packets will route through one machine. A default routing machine must exist on the same subnet as each system using it.

To create a default router, you'll only need to create the file /etc/defaultrouter on each of your systems. The single line in the file should contain the name of your routing machine. For example, systems on the same subnet using the default router widget1 should have the file /etc/defaultrouter containing the line

widget1

Those of you using Solaris 2.4 or later can list multiple routers in your /etc/defaultrouter file. Each line in the file should contain the name of a routing machine on the same subnet. For each entry in this file, you must include a complete entry in the /etc/hosts file. If, for example, you have the two routers

router-1

router-2

in your /etc/defaultrouter file, your /etc/hosts file should contain the entries

140.244.96.1 router-1

140.244.96.2 router-2

Once you make these changes, reboot your system for them to take effect. This is the simplest way to make sure that routing is working.

Adding static routes with route

At any time, you can add static routes to your machine via the route command. The standard syntax used with this command is

route add net remote-network-ip gateway-ip

hop-count

The remote-network-ip variable is the IP address of the network you want to add a route to, and the gateway-ip variable is the IP address of the gateway that leads to that remote network. The hop-count variable refers to the number of gateways you must pass through to get to the remote network. Let's take a look at an example.

Your system has an IP address of 140.244.96.1. Your default router serves as a gateway to another network with a default router whose IP address is 140.244.97.0. To create a static route using the route command from your system to the other network, enter the command

route add net 140.244.96.1 140.244.97.0 1

Since the route passes through only one router, the hop-count is one.

If your system uses the in.routed daemon, you canĂ­t add static routes with the above method. When you try to add a static route with this daemon running, in.routed will remove them after 90 seconds. If you're using in.routed and want to use static routes, you must include them in the /etc/gateways file. We'll explain this during our discussion of the in.routed daemon.

When to use the in.rdisc daemon

As we explained earlier, when your system boots and doesn't find the /etc/defaultrouter file, the in.rdisc daemon automatically loads. If another router on your system broadcasts Router Discovery Packets, the daemon will continue running. Upon finding no Router Discovery Packets, the daemon will automatically terminate.

As a general rule, the in.rdisc daemon will run on all Solaris systems configured as routers. If you want to decrease network traffic on a large network, you can disable the in.rdisc daemon by simply renaming the file. You should run this daemon on routing hosts when your local network is fairly complex.

Using the in.routed daemon

On Solaris systems, the in.routed daemon starts automatically if no default router is defined in /etc/defaultrouter. On host systems, the in.routed daemon loads only after in.rdisc fails and terminates. On routers, the in.routed daemon loads even with in.rdisc running.

If you want to force in.routed to load network routes, you can create an /etc/gateways file with entries using the syntax

net (remote-network-ip) gateway (gateway-ip)

metric (hop-count) active/passive

This is similar to the syntax used with the route command, with a little variation. The active/passive entry determines the permanence of a route defined in /etc/gateways. If you specify an entry as active, in.routed will query the gateway host occasionally. If the route becomes inactive, in.routed will remove it. If you specify an entry as passive, the route will remain regardless of its activity.

In addition to forcing network routes, the /etc/gateways file can specify whether an interface can send or receive RIP packets by using the syntax

norip (interface)

noripin (interface)

noripout (interface)

When you create an entry such as

norip le0

in /etc/gateways, no RIP packets can enter or leave through the specified interface. This can be especially helpful to suppress broadcast RIP packets for security reasons on a given interface.

Conclusion

Routing packets is the unseen and often unknown work of your network. By having a better understanding of routing and how it works, you can develop new strategies for optimizing network traffic. In this article, we discussed routing on Solaris systems. We also discussed the routing daemons and how they work.


[Return to Index for Inside Solaris - February 1996 Issue]

Copyright (c) 1996 The Cobb Group, a division of Ziff-Davis Publishing Company. All rights reserved. Reproduction in whole or in part in any form or medium without express written permission of Ziff-Davis Publishing Company is prohibited. The Cobb Group and The Cobb Group logo are trademarks of Ziff-Davis Publishing Company.

Inside Solaris is a publication of The Cobb Group.
1-800-223-8720